package cn.com.twoke.game.client.games;

import cn.com.twoke.game.client.games.gomoku.GomokuGame;
import cn.com.twoke.game.client.games.gomoku.controller.NioController;
import cn.com.twoke.game.client.games.gomoku.controller.RobotController;
import cn.com.twoke.game.client.games.gomoku.handler.GomokuGameDataHandler;
import cn.com.twoke.game.client.games.tic_tac_toe.TicTacToeGame;
import cn.com.twoke.game.client.games.tic_tac_toe.controller.NioChessController;
import cn.com.twoke.game.client.games.tic_tac_toe.controller.RobotChessController;
import cn.com.twoke.game.client.games.tic_tac_toe.handler.TicTacToeGameDataHandler;
import cn.com.twoke.game.common.handler.GameDataHandler;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class GameManager {

    public static final List<GameConfig> GAMES = new ArrayList<>();

    public static final Map<String, GameDataHandler> GAME_DATA_HANDLER_MAP = new HashMap<>();

    static {
        GAMES.add(new GameConfig(GomokuGame.ID, GomokuGame.TITLE, (ctx) ->
                ctx.getPlayerCount() == 1 ? new GomokuGame(new RobotController()) :
                        new GomokuGame(new NioController()),
                2,
                1));
        GAMES.add(new GameConfig(TicTacToeGame.ID, TicTacToeGame.TITLE, (ctx) ->
                ctx.getPlayerCount() == 1 ? new TicTacToeGame(new RobotChessController()) :
                        new TicTacToeGame(new NioChessController()),
                2,
                1));
        GAME_DATA_HANDLER_MAP.put(GomokuGame.ID, new GomokuGameDataHandler());
        GAME_DATA_HANDLER_MAP.put(TicTacToeGame.ID, new TicTacToeGameDataHandler());
    }


}
